package com.tianyang.yukuaifuzs.business.trade.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.alibaba.fastjson.JSONObject;
import com.tianyang.yukuaifuzs.R;
import com.tianyang.yukuaifuzs.utils.VerifyUtil;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Description：结算方式顶部view
 * Created by xyj on 2024/3/11
 */
public class SettleMethodHeaderView extends LinearLayout {

    @BindView(R.id.withdrawAmountTv)
    TextView withdrawAmountTv;
    @BindView(R.id.feeTv)
    TextView feeTv;
    @BindView(R.id.singleFeeTv)
    TextView singleFeeTv;
    @BindView(R.id.totalTv)
    TextView totalTv;

    public SettleMethodHeaderView(Context context, AttributeSet attrs) {
        super(context, attrs);
        View.inflate(getContext(), R.layout.layout_settle_method_header, this);
        ButterKnife.bind(this);
    }

    public void showSettleTotalView(JSONObject jsonObject) {
        if (jsonObject != null) {
            if (jsonObject.containsKey("withdrawAmount")) {
                withdrawAmountTv.setText(VerifyUtil.decimalFormat(jsonObject.getString("withdrawAmount")));
            }
            if (jsonObject.containsKey("fee")) {
                feeTv.setText(VerifyUtil.decimalFormat(jsonObject.getString("fee")));
            }
            if (jsonObject.containsKey("singleFee")) {
                singleFeeTv.setText(VerifyUtil.decimalFormat(jsonObject.getString("singleFee")));
            }
            StringBuffer stringBuffer = new StringBuffer();
            stringBuffer.append("待结算总笔数：");
            if (jsonObject.containsKey("tradeCount"))
                stringBuffer.append(jsonObject.getString("tradeCount"));
            else
                stringBuffer.append("0");
            stringBuffer.append("，总交易金额：");
            if (jsonObject.containsKey("amount"))
                stringBuffer.append(VerifyUtil.decimalFormat(jsonObject.getString("amount")));
            else
                stringBuffer.append("0.00");
            stringBuffer.append("元");
            totalTv.setText(stringBuffer);
        }
    }
}
